package com.dongdongshop.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dongdongshop.data.DataResult;
import com.dongdongshop.data.ResponseStausEnum;
import com.dongdongshop.pojo.TbBrand;
import com.dongdongshop.pojo.TbContent;
import com.dongdongshop.service.ContentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Description
 * @ClassName ContentController
 * @Author RC
 * @date 2020.12.16 21:27
 */
@Controller
@RequestMapping("content")
public class ContentController {
    @Reference(timeout = 1000000,check = false)
    private ContentService contentService;
    private static final Logger logger = LoggerFactory.getLogger(ContentController.class);

    //轮播图展示
    @RequestMapping("getContentForBanner")
    @ResponseBody
    public DataResult getContentForBanner() {
        try {
            logger.info("进入轮播图展示方法");
            List<TbContent> tbContents = contentService.getContentForBanner();
            return DataResult.response(ResponseStausEnum.SUSSCESS).setData(tbContents);

        } catch (Exception e) {
            logger.info("查询失败", e);
            return DataResult.response(ResponseStausEnum.INTERNAL_SERVER_ERROR);
        }
    }
    //今日推荐
    @RequestMapping("getContenttodayShow")
    @ResponseBody
    public DataResult getContenttodayShow() {
        try {
            logger.info("进入今日推荐方法");
            List<TbContent> tbContents = contentService.getContenttodayShow();
            return DataResult.response(ResponseStausEnum.SUSSCESS).setData(tbContents);

        } catch (Exception e) {
            logger.info("查询失败", e);
            return DataResult.response(ResponseStausEnum.INTERNAL_SERVER_ERROR);
        }
    }
    //猜你喜欢
    @RequestMapping("getContentLikeShop")
    @ResponseBody
    public DataResult getContentLikeShop() {
        try {
            logger.info("进入今日推荐方法");
            List<TbContent> tbContents = contentService.getContentLikeShop();
            return DataResult.response(ResponseStausEnum.SUSSCESS).setData(tbContents);

        } catch (Exception e) {
            logger.info("查询失败", e);
            return DataResult.response(ResponseStausEnum.INTERNAL_SERVER_ERROR);
        }
    }

 }
